<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Wireframe extends CI_Controller {

 
	function __construct()
	{
		parent::__construct();
		
		// check if user logged in 
		/*if (!$this->ion_auth->logged_in())
	  	{
			redirect('auth/login');
	  	}*/
		$this->load->model('user/user_model');
		$this->load->model('user/wireframe_model');
		$this->load->model('ion_auth_model');	
			
	}
		
   function index()
   {
		
	   	$page = $this->session->flashdata('page');	
	   	$meta['page_title'] = "Fedobe Wireframe Prototyping";			
		$data['user'] = $this->wireframe_model->get_user_details($this->session->userdata('user_id'));	
		//echo '<pre>';
		//print_r($data);
		$this->load->view('common/header', $meta);   
	   	$this->load->view('user/view-wireframe',$data);
       	$this->load->view('common/footer');
		
   }
   function add_tag(){
   	
		$config['upload_path'] = './assets/images/tags/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '20000000';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
		
			
        $this->load->library('upload', $config);
        $this->upload->do_upload('file');
		
        //$data = $this->upload->data();
		$data = array('upload_data' => $this->upload->data());
		
		$users = $this->input->post('users');	
		$name=$data['upload_data' ]['file_name'];
	   		$add = array(
			'user_id' => $this->session->userdata('user_id'),	
			'heading' => $this->input->post('heading'),
			'parent' => $this->input->post('parent'),
			'image_name' => $name,
			
			);
			
			$this->wireframe_model->add_wireframe($data,$add);
			redirect('user/wireframe','refresh',$data);
   	}
	

	
	
		
	function update_tag(){
		
		$heading = $this->input->post('headingup');
		$update = array(
			'user_id' => $this->session->userdata('user_id'),	
			'parent' => $this->input->post('parentup'),
			);

			$this->wireframe_model->update_wireframe($update,$heading);
			redirect('user/wireframe','refresh');
		
		}
		
		function delete_tag(){
		
		$heading = $this->input->post('headingd');
	
			$this->wireframe_model->delete_wireframe($heading);
			redirect('user/wireframe','refresh');
		
		}
		
	function tag_picture()
		{
			$page = $this->session->flashdata('page');	
	   		$meta['page_title'] = "Fedobe Wireframe Prototyping";			
			$data['user'] = $this->wireframe_model->get_user_details($this->session->userdata('user_id'));
			$this->wireframe_model->getpicturetag();
			//echo '<pre>';
			//print_r($data);
			$this->load->view('common/header', $meta);   
	   		$this->load->view('user/tag-picture',$data);
       		$this->load->view('common/footer');
		}
		
	function savetag()
		{
			$this->load->view('user/savetag');
		}
	
	function taglist()
		{  
			$this->load->view('user/taglist');
		}
	
	
	

	
}
	
	?>